import {Component, ViewChild} from '@angular/core';
import {HttpClient} from '../../../../providers/httpClient';
import _ from 'lodash';
import {NavParams} from "ionic-angular";

@Component({
  selector: 'page-marketing-credit-listDetail',
  templateUrl: './listDetail.html'
})

export class MarketingCreditListDetailPage {
  moa_page_name: any = "page-marketing-credit-listDetail";
  moa_page_explain: any = "营销平台 - 机构客户诚信详情";

  managerData = null;
  transActionData = [];

  constructor(private navParams: NavParams, private httpClient: HttpClient) {
    this.managerData = navParams.get('item');
    this.getTransaction();
  }

  getTransaction() {
    console.log(this.managerData[1]);
    let postBody = {
      "module": "KSB",
      "method": "USP_A02_0250",
      "type": "USP",
      "params": {
        'c_managername_i': this.managerData[1],
      }
    };
    this.httpClient.post(postBody).subscribe(data => {
      if (data) {
        let dataList = [];
        _.forEach(data, (i) => {
          let d = i.split("|");
          d[10] = d[10].split(/##|;/);
          _.forEach(d[10], (i, index: any) => {
            if (i == "") {
              d[10].splice(index, 1);
            }
          })
          // d[10]=d[10].replace(new RegExp('##',"gm"),"\n");
          d[d.length] = false;
          dataList.push(d);
        });
        this.transActionData = dataList;
      }
    });
  }

  changeShow(item) {
    item[item.length - 1] = !item[item.length - 1];
  }
}


